Indice de position sociale / Social position index

public policy
code
analysis
Author

Olivier Caron

Published

May 15, 2023

This is a post with executable code.

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.2     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.2     ✔ tibble    3.2.1
✔ lubridate 1.9.2     ✔ tidyr     1.3.0
✔ purrr     1.0.1     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(esquisse)
library(readr)
library(reactable)
ips_colleges <- read_delim("ips_colleges.csv")
Rows: 41701 Columns: 11
── Column specification ────────────────────────────────────────────────────────
Delimiter: ";"
chr (9): Rentrée scolaire, Académie, Code du département, Département, UAI, ...
dbl (2): IPS, Ecart-type de l'IPS

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
ips_lycees <- read_delim("ips_lycees.csv")
Rows: 21777 Columns: 15
── Column specification ────────────────────────────────────────────────────────
Delimiter: ";"
chr (10): Rentrée scolaire, Académie, Code du département, Département, UAI,...
dbl  (5): IPS voie GT, IPS voie PRO, IPS Ensemble GT-PRO, Ecart-type de l'IP...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
column_names_colleges <- c("school_year", "academy", "code_department", "department", "uai", "institution_name", "insee_code_commune", "commune_name", "sector", "ips", "sd_ips")

column_names_lycees <- c("school_year", "academy", "code_department", "department", "uai", "institution_name", "insee_code_commune", "commune_name", "sector", "lycee_type", "ips_gt", "ipd_pro", "ips", "sd_ips_gt", "sd_ips_pro")

#modify column names
names(ips_colleges)[1:11] <- column_names_colleges
names(ips_lycees)[1:15] <- column_names_lycees

ips_colleges["school_type"] <- "college"
ips_lycees["school_type"] <- "lycee"

ips_data <- bind_rows(ips_colleges,ips_lycees)
write_csv(ips_data,"ips_data.csv")
#write.csv(ips_data, "ips_data.csv", na = "", fileEncoding = "UTF-8")
ips_data_reduced <- ips_data %>%
  select(school_year, school_type, ips, sector, institution_name, commune_name) %>%
  rename(
    "School Year" = school_year,
    "School Type" = school_type,
    "IPS" = ips,
    "Sector" = sector,
    "Institution Name" = institution_name,
    "Commune Name" = commune_name
  )

reactable(ips_data_reduced, filterable = TRUE, sortable = TRUE, bordered = TRUE)